// 过去日期数组
const getPastDateArray = [
  {
    text: '最近一个月',
    value: 1
  },
  {
    text: '最近三个月',
    value: 3
  },
  {
    text: '最近半年',
    value: 6
  },
  {
    text: '最近一年',
    value: 12
  },
  {
    text: '最近两年',
    value: 24
  },
  {
    text: '最近三年',
    value: 36
  }
];

export const useMonthShortcuts = (endMonth: number = 24) => {
  return getPastDateArray
    .filter((item) => item.value <= endMonth)
    .map((item) => {
      return {
        text: item.text,
        value: () => {
          const end = new Date();
          const start = new Date(new Date().setMonth(new Date().getMonth() - item.value));
          return [start, end];
        }
      };
    });
};
